<?php

namespace pay\modules\backend\models;

use Yii;

/**
 * This is the model class for table "pay_order".
 *
 * @property int $oid
 * @property int $app_id appId
 * @property int $aid aid
 * @property string $pay_order_sn 支付单号
 * @property string $mar_order_sn 商户单号
 * @property string $wechat_order_sn 微信单号
 * @property string $ref_order_sn 退款单号
 * @property int $real_money 实际支付金额
 * @property int $pay_status 1-订单生成，2-支付中，3-支付成功，4-处理完成，5-已退款
 * @property string $pay_times 支付时间
 * @property string $create_time 订单创建时间
 */
class Order extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'pay_order';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['app_id', 'aid', 'pay_order_sn', 'mar_order_sn'], 'required'],
            [['app_id', 'aid', 'real_money', 'pay_status'], 'integer'],
            [['pay_times', 'create_time'], 'safe'],
            [['pay_order_sn', 'mar_order_sn', 'ref_order_sn'], 'string', 'max' => 32],
            [['wechat_order_sn'], 'string', 'max' => 64],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'oid' => 'Oid',
            'app_id' => 'App ID',
            'aid' => 'Aid',
            'pay_order_sn' => 'Pay Order Sn',
            'mar_order_sn' => 'Mar Order Sn',
            'wechat_order_sn' => 'Wechat Order Sn',
            'ref_order_sn' => 'Ref Order Sn',
            'real_money' => 'Real Money',
            'pay_status' => 'Pay Status',
            'pay_times' => 'Pay Times',
            'create_time' => 'Create Time',
        ];
    }


    public function getDetails()
    {
        $data = $this->hasOne(OrderDetails::className(),['oid' => 'oid']);
        return $data;
    }
    
    
}
